package com.da.javatest.leetCode;

import java.util.Arrays;

/**
 * @author chenlida
 * @date 2019/3/8 11:55
 * @description
 */
public class Code532 {
    public int findPairs(int[] nums, int k) {
        int count = 0;
        int last = Integer.MIN_VALUE;
        Arrays.sort(nums);
        for (int i = 0; i < nums.length; i++) {
            int n = nums[i];
            if (last == n) {
                continue;
            }
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[j] - n == k) {
                    count++;
                    break;
                }
            }
            last = n;
        }
        return count;
    }
}
